public class BubbleSort {
    public static void main(String[] args) {
        int []num = {2, 4, 0, 5, 7, 1, 3, 8, 9};
        for (int i= 0; i< num.length; i++)
            System.out.print(num[i]);
        //外层循环为：数组长度减一
        for (int i = 0; i < num.length-1; i++){
            //内层循环为：数组长度-外层循环数-1
            for (int j = 0; j < num.length-i-1; j++){
                //如果第一个数大于第二个数，交换二者位置
                if (num[j] > num[j+1]) {
                    int temp = num[j];
                    num[j] = num[j + 1];
                    num[j + 1] = temp;
                }
            }
        }
        System.out.println();
        for (int i= 0; i< num.length; i++)
            System.out.print(num[i]);
    }

}
